﻿@namespace LaserMark.Components
@inherits BootstrapComponentBase

<div @attributes="@AdditionalAttributes" class="@HeaderClassString">
    <div class="ribbon-header">
        <div class="tabs tabs-top">
            <div class="tabs-body">
                @foreach (var item in Items)
                {
                    <div class="tabs-body-content">
                        <div class="tab-commands">
                            @foreach (var groups in item.Items.OfType<RibbonTabItem>().GroupBy(s => s.GroupName))
                            {
                                <div class="link-group">
                                    <div class="d-flex">
                                        @foreach (var group in groups)
                                        {
                                            if (group.Component != null || group.Template != null)
                                            {
                                                @RenderTemplate(group)
                                            }
                                            else
                                            {
                                                <LinkButton Icon="@group.Icon" ImageUrl="@group.ImageUrl" IsDisabled="@group.IsDisabled"
                                                            Url="@group.Url" Target="@group.Target"
                                                            Text="@group.Text" IsVertical="true" Color="Color.None"
                                                            class="@GetClassString(group)" StopPropagation="true" OnClick="() => OnItemClickAsync(group)" />
                                            }
                                        }
                                    </div>
                                    <div class="link-group-name">
                                        @groups.Key
                                    </div>
                                </div>
                                <Divider IsVertical="true" />
                            }
                            @if (IsStop && !IsOff)
                            {
                                <div style="color:#b33332;font-size:36px;align-self:center">
                                    PLC 急停
                                </div>
                            }

                            @if (IsTimeout && !IsOff && !IsStop)
                            {
                                <div style="color:#b33332;font-size:36px;align-self:center">
                                    上片超时
                                </div>
                            }
                            @if (IsLimit && !IsOff && !IsStop)
                            {
                                <div style="color:#b33332;font-size:36px;align-self:center">
                                    限位报警
                                </div>
                            }
                            @if (IsZeroBack && !IsOff && !IsStop)
                            {
                                <div style="color:#b33332;font-size:36px;align-self:center">
                                    机械未回零
                                </div>
                            }

                            @if (IsScan && !IsOff)
                            {
                                <div style="color:#b33332;font-size:36px;align-self:center">
                                    @Message
                                </div>
                            }

                            @if (IsOff)
                            {
                                <div style="color:#b33332;font-size:36px;align-self:center">
                                    电源关闭
                                </div>
                            }

                            @if (IsShownProduct && !IsOff && !IsStop && !IsZeroBack)
                            {
                                <div style="color:#b33332;font-size:36px;align-self:center">
                                    @GlobalStatus.ProductMessage
                                </div>
                            }
                        </div>
                    </div>
                }
            </div>
        </div>
    </div>
</div>
